# -*- coding: utf-8 -*- 
# @project : 《Atcoder》
# @Author : created by bensonrachel on 2021/6/26
# @File : C - Bowls and Dishes（生成组合）.py

N, M = map(int, input().split())#生成组合，二进制
char1 = []
for _ in range(M):
    A, B = map(int, input().split())
    a = (A, B)
    char1.append(a)
K = int(input())
char2 = []
for _ in range(K):
    C, D = map(int, input().split())
    a = (C, D)
    char2.append(a)
def re(tag):
    cnt = 0
    for i in char1:
        if( tag[i[0]] and tag[i[1]] ):
            cnt += 1
    return cnt
def cal(x):
    tag = [0]*105
    for i in range(K):
        if (x>>i)&1 :tag[char2[i][1]] = 1
        else: tag[char2[i][0]] = 1
    x = re(tag)
    return x
char3 = []
for i in range(0,1<<K):
    res = cal(i)
    char3.append(res)
print(max(char3))
